<div id="search">
<script>
$(document).ready(function(){
function khoainput(){
	var ma = $('input[name=ma]').val();
	var ten = $('input[name=ten]').val();
	if((ma=='Mã') && (ten=='Tên')){
		$('input[name=btnSearch]').attr('disabled',true);
	} else $('input[name=btnSearch]').attr('disabled',false);
}
khoainput();
	$('input[name=ma],input[name=ten]').blur(function(){ khoainput(); });
});
</script>
<form action="administrator.php" method="get" name="kiemtra">
	<input type="hidden" name="p" value="<?php echo $p?>" />
	<input type="text" name="ma" class="txt" value="<?php if(@$_GET['ma']) echo $_GET['ma']; else echo 'Mã';?>" onClick="if(value=='Mã') value=''" onBlur="if(value=='') value='Mã'" />
	<input type="text" name="ten" class="txt" value="<?php if(@$_GET['ten']) echo $_GET['ten']; else echo 'Tên';?>" onClick="if(value=='Tên') value=''" onBlur="if(value=='') value='Tên'" />
    <input type="submit" name="btnSearch" value="Tìm" class="btn" />
</form>
</div>
<?php
if(@$_GET['btnSearch']){
	$ma = trim($_GET['ma']);
	$ten = trim($_GET['ten']);
	$qr = "SELECT * FROM {$p} WHERE `delete`=0 ";
	if($ma != 'Mã') $qr .= " AND id='{$ma}' ";
	if($ten != 'Tên') $qr .= " AND ten LIKE '%{$ten}%' ";
	$qr .= ' ORDER BY ten';
	$sql = mysql_query($qr);
}
?>
<div class='row' style="background-color:#88C4FF; font-weight:bold">
    <div class='col_0'>STT</div>
    <div class='col_1'>Mã môn</div>
    <div class='col_4'>Tên môn</div>
    <div class='col_2'>Điện thoại</div>
    <div class='col_4'>Ghi chú</div>
    <div class='col_create'>Người đăng</div>
    <div class='col_create'>Ngày đăng</div>
    <div class='col_update'>Người cập nhật</div>
    <div class='col_update'>Ngày cập nhật</div>
    <div class='col_1'>Thao tác</div>
    <div style='clear:both'></div>
</div>
<?php
while($row_sql = mysql_fetch_array($sql)){
	$g++; $stt = $start+$g;
	($row_sql['date_update']=='') ? $date_up = '' : $date_up = date('d-m-Y',strtotime($row_sql['date_update']));
	echo "<div class='row'>
    <div class='col_0'>".$stt."</div>
    <div class='col_1'>{$row_sql['id']}</div>
    <div class='col_4'>{$row_sql['ten']}</div>
    <div class='col_2'>{$row_sql['dienthoai']}</div>
    <div class='col_4'>{$row_sql['notes']}</div>
    <div class='col_create'>{$row_sql['user_create']}</div>
    <div class='col_create'>".date('d-m-Y',strtotime($row_sql['date_create']))."</div>
    <div class='col_update'>{$row_sql['user_update']}</div>
    <div class='col_update'>{$date_up}</div>
    <div class='col_1'>".thaotac($page,$row_sql['id'])."</div>
    <div style='clear:both'></div>
</div>";
}
mysql_free_result($sql);